package com.mallcloud.mall.app.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mallcloud.mall.app.api.entity.AppXglSaleBillModel;
import com.mallcloud.mall.app.api.entity.dto.AppOrderXglPageDTO;
import com.mallcloud.mall.app.mapper.AppSalePaySummaryMapper;
import com.mallcloud.mall.app.mapper.AppXglQRCodePaymentMapper;
import com.mallcloud.mall.app.service.AppXglSaleBillService;
import com.mallcloud.mall.common.core.exception.FailException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class AppXglCashRegisterServiceImpl extends ServiceImpl<AppSalePaySummaryMapper, AppXglSaleBillModel> implements AppXglSaleBillService {
	private final AppXglQRCodePaymentMapper appXglQRCodePaymentMapper;

	@Override
	public Page pageSaleBill(Page<AppXglSaleBillModel> page, AppOrderXglPageDTO dto) {
		String cabinetGroupCode = appXglQRCodePaymentMapper.getCabinetGroupCode(dto.getPhone());
		if (StrUtil.isBlank(cabinetGroupCode)) {
			throw new FailException("用户不存在");
		}
		dto.setCabinetGroupCode(cabinetGroupCode);
		return this.baseMapper.pageSaleBill(page, dto);
	}
}
